﻿package com.plter.controls.asmax
{
	import flash.display.Shape;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	/**
	 * ...
	 * @author Jaja as-max.cn
	 */
	internal class AShutButton extends ASprite
	{
		/**
		 * 关闭图形X的路径
		 */
		private const POINTS1:Array = [new Point(0, 0), new Point(9, 9)];
		private const POINTS2:Array = [new Point(9, 0), new Point(0, 9)];
		
		/**
		 * 关闭图形的容器
		 */
		private var shutShape:Shape = new Shape;
		
		public function AShutButton() :void
		{
			//绘制背景
			drawBG(18, 16, 0xF0F0F0, 0xDDDDDD, 5, 5);
			bgAlpha = 0.01;
			
			
			//绘制关闭图形
			shutShape.graphics.lineStyle(2, 0x000000);
			drawPathOnShape(POINTS1, shutShape);
			drawPathOnShape(POINTS2, shutShape);
			shutShape.x = (this.width - shutShape.width) / 2 + .5;
			shutShape.y = (this.height - shutShape.height) / 2 + .5;
			addChild(shutShape);
			
			this.addEventListener(MouseEvent.MOUSE_OVER, mouseEventHandler);
			this.addEventListener(MouseEvent.MOUSE_OUT, mouseEventHandler);
		}
		
		private function mouseEventHandler(event:MouseEvent):void {
			switch(event.type) {
				case MouseEvent.MOUSE_OUT:
					bgAlpha = 0.01;
					break;
				case MouseEvent.MOUSE_OVER:
					bgAlpha = 1;
					break;
			}
		}
		
	}
	
}